<?php
namespace app\web\validate;

use think\Validate;

/**
 * 行为验证器
 * @package app\menus\validate
 * @author
 */
class User extends Validate
{
    //定义验证规则
    protected $rule = [
        'id|员工ID'=>'require|number',
        'phone|手机号'  => 'require|mobile',
        'code|验证码'  => 'require|number',
        'password|密码'  => 'require|alphaNum|length:6,12',
        'safeword|安全码'  => 'require|number|length:6',
        'old_safeword|安全码'  => 'require|number|length:6',
        'new_password|密码'  => 'require|alphaNum|length:6,12',
        'new_safeword|安全码'  => 'require|number|length:6',
        'type|类型'  => 'require|number',
        'old_password|密码'  => 'require|alphaNum|length:6,12',

        'work_number|工号'  => 'require',
        'real_name|姓名'  => 'require',
        'sex|性别'  => 'require',
        'age|年龄'  => 'require',
        'type_id|工种'  => 'require',
        'work_time|入职时间'  => 'require',
        'overtime|超时时间'  => 'require',
        'is_open|下单'  => 'require',
        'is_recharge|充值'  => 'require',
        'is_pay|支付'  => 'require',
        'is_retreat|退钟'  => 'require',
        'is_room|房间'  => 'require',
        'is_hand_card|手牌'  => 'require',
        'is_room_content|备注'  => 'require',
        'project_ids|服务项目'  => 'require',
    ];
    //定义验证提示
    protected $message = [
        'id.require' => '请填写员工ID',
        'id.number' => '员工ID是一个数字',
        'phone.require' => '请填写手机号',
        'phone.mobile' => '请填写正确的手机号',
        'code.require' => '请输入验证码',
        'code.number' => '验证码格式不正确',
        'password.require' => '请填写密码',
        'password.alphaNum' => '密码只能是字母或者数字',
        'password.length' => '密码长度不正确',
        'safeword.require' => '请填写安全码',
        'safeword.number' => '安全码格式不正确',
        'safeword.length' => '安全码长度不正确',
        'new_password.alphaNum' => '密码只能是字母或者数字',
        'new_password.length' => '密码长度不正确',
        'new_password.require' => '请填写密码',
        'type.require' => '请填写类型',
        'type.number' => '类型必须为数字',
        'old_password.require' => '请填写密码',
        'old_password.alphaNum' => '密码只能是字母或者数字',
        'old_password.length' => '密码长度不正确',
        'old_safeword.require' => '请填写安全码',
        'old_safeword.number' => '安全码格式不正确',
        'old_safeword.length' => '安全码长度不正确',
        'new_safeword.require' => '请填写安全码',
        'new_safeword.number' => '安全码格式不正确',
        'new_safeword.length' => '安全码长度不正确',

        'work_number.require' => '请填写工号',
        'real_name.require' => '请填写姓名',
        'sex.require' => '请选择性别',
        'age.require' => '请填写年龄',
        'type_id.require' => '请选择工种',//职务
        'work_time.require' => '请填写入职时间',
        'overtime.require' => '请填写超时时间',
        'is_open.require' => '请填写下单权限',
        'is_recharge.require' => '请填写充值权限',
        'is_pay.require' => '请填写支付权限',
        'is_retreat.require' => '请填写退钟权限',
        'is_room.require' => '请填写房间状态权限',
        'is_hand_card.require' => '请填写手牌结账权限',
        'is_room_content.require' => '请填写显示房间备注权限',
        'project_ids.require' => '请选择服务项目',
    ];

    //定义验证场景
    protected $scene = [
        'add'            =>  ['phone'],
        'add_engineer'   =>  ['phone','work_number','real_name','sex','type_id','is_open','is_recharge','is_pay','is_retreat','is_room','is_hand_card','is_room_content','project_ids'],
        'edit_engineer'  =>  ['id','phone','work_number','real_name','sex','type_id','is_open','is_recharge','is_retreat','is_room','is_hand_card','is_room_content','project_ids'],
        'add_floor'      =>  ['work_number','card','phone','real_name','sex','work_time','post_id','sex','work_time','select_report_time','select_list_time','hand_code','operation'],
        'edit_floor'      =>  ['id','work_number','card','phone','real_name','sex','work_time','post_id','sex','work_time','select_report_time','select_list_time','hand_code','operation'],
        'add_staff'      =>  ['phone','real_name','sex','type_id','work_time',],
        'add_save'       =>  ['phone','real_name','sex','type_id','work_time',],

    ];
}
